﻿using PMS.Domain.AggregatesModel.MessaeAggregate;
using PMS.Domain.Seedwork;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;

namespace PMS.Infrastructure.Repositories
{
    public class MessageCenterRepository : IMessageCenterRepository
    {
        public readonly PMSContext _dbContext;

        public MessageCenterRepository(PMSContext pMSContext )
        {
            _dbContext = pMSContext;
        }
        public IUnitOfWork UnitOfWork => _dbContext;

        public async Task CreateAsync(MessageCenter messageCenter)
        {
           await _dbContext.MessageCenters.AddAsync(messageCenter);
        }

        public async Task<MessageCenter> GetMessageByIdAsync(int id)
        {
            return await _dbContext.MessageCenters.FirstOrDefaultAsync(b => b.Id == id);
        }
   
        public void Update(MessageCenter messageCenter)
        {
            _dbContext.MessageCenters.Update(messageCenter);
        }
    }
}
